From: Carlos Garnacho Date: Fri, 5 Aug 2022 14:39:56 +0000 (+0200) Subject: gtkwindow: Synthesize pointer crossing events on state changes X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~81^2^2~14^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=adba0b972e2a86d8f169222d7e64c346dc746325;p=gtk4.git gtkwindow: Synthesize pointer crossing events on state changes When widgets go mapped/unmapped, we repick but don't generate crossing events. Since there could be stateful controllers that use those in the previously picked widget (e.g. GtkEventControllerMotion), skipping those breaks their state. Ensure to send the relevant crossing events on every situation that changes the pointer focus, so these controllers get a fair opportunity to undo their state. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2877 --- diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 2c8c5502e8..7d7c4a312b 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -4968,6 +4968,9 @@ synthesize_focus_change_events (GtkWindow *window, GtkWidget *prev; gboolean seen_ancestor; + if (old_focus == new_focus) + return; + if (old_focus && new_focus) ancestor = gtk_widget_common_ancestor (old_focus, new_focus); else @@ -6455,7 +6458,12 @@ gtk_window_update_pointer_focus_on_state_change (GtkWindow *window, else if (focus->target == widget || gtk_widget_is_ancestor (focus->target, widget)) { + GtkWidget *old_target; + + old_target = g_object_ref (focus->target); gtk_pointer_focus_repick_target (focus); + synthesize_focus_change_events (window, old_target, focus->target, GTK_CROSSING_POINTER); + g_object_unref (old_target); } gtk_pointer_focus_unref (focus);